home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MotifComboBoxRenderer.java < prev    next >
Text File  |  1998-06-30  |  3KB  |  110 lines

  1. /*
  2.  * @(#)MotifComboBoxRenderer.java    1.5 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.plaf.motif;
  21.  
  22. /**
  23.  * A renderer for combo box with motif look and feel
  24.  *
  25.  * @version 1.5 02/02/98
  26.  * @author Arnaud Weber
  27.  */
  28.  
  29. import com.sun.java.swing.*;
  30. import com.sun.java.swing.event.*;
  31. import com.sun.java.swing.border.*;
  32.  
  33. import java.awt.Component;
  34. import java.awt.Color;
  35.  
  36. import java.io.Serializable;
  37.  
  38. /**
  39.  * Motif rendition of the combo box renderer.
  40.  * <p>
  41.  * Warning: serialized objects of this class will not be compatible with
  42.  * future swing releases.  The current serialization support is appropriate
  43.  * for short term storage or RMI between Swing1.0 applications.  It will
  44.  * not be possible to load serialized Swing1.0 objects with future releases
  45.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  46.  * baseline for the serialized form of Swing objects.
  47.  */
  48. public class MotifComboBoxRenderer extends JLabel
  49.     implements ListCellRenderer, Serializable
  50. {
  51.     protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
  52.  
  53.     public MotifComboBoxRenderer() {
  54.     super();
  55.     setOpaque(true);
  56.     setBorder(noFocusBorder);
  57.     }
  58.  
  59.  
  60.     public Component getListCellRendererComponent(
  61.         JList list, 
  62.     Object value,
  63.         int index, 
  64.         boolean isSelected, 
  65.         boolean cellHasFocus)
  66.     {
  67.  
  68.         setHorizontalAlignment(SwingConstants.LEFT);
  69.         if (isSelected) {
  70.             setBackground(list.getSelectionBackground());
  71.             setForeground(list.getSelectionForeground());
  72.         } else {
  73.             setBackground(list.getBackground());
  74.             setForeground(list.getForeground());
  75.         }
  76.     
  77.     if (value instanceof Icon) {
  78.         setIcon((Icon)value);
  79.     }
  80.     else {
  81.         setText((value == null) ? "" : value.toString());
  82.     }
  83.     return this;
  84.     }
  85.  
  86.  
  87.     /**
  88.      * A subclass of MotifComboBoxRenderer that implements UIResource.
  89.      * MotifComboBoxRenderer doesn't implement UIResource
  90.      * directly so that applications can safely override the
  91.      * cellRenderer property with MotifListCellRenderer subclasses.
  92.      * <p>
  93.      * Warning: serialized objects of this class will not be compatible with
  94.      * future swing releases.  The current serialization support is appropriate
  95.      * for short term storage or RMI between Swing1.0 applications.  It will
  96.      * not be possible to load serialized Swing1.0 objects with future releases
  97.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  98.      * baseline for the serialized form of Swing objects.
  99.      */
  100.     public static class UIResource extends MotifComboBoxRenderer 
  101.         implements com.sun.java.swing.plaf.UIResource
  102.     {
  103.     }
  104.  
  105.  
  106.  
  107. }
  108.  
  109.  
  110.